home *** CD-ROM | disk | FTP | other *** search
/ Aminet 8 / Aminet 8 (1995)(GTI - Schatztruhe)[!][Oct 1995].iso / Aminet / disk / cdrom / CDR210kit.lha / nectools / eject.c < prev    next >
C/C++ Source or Header  |  1995-05-11  |  1KB  |  71 lines

  1. /*
  2.     NEC-CDR-210 Eject
  3.  
  4.     by dbalster@uni-paderborn.de
  5. */
  6.  
  7. #include <exec/exec.h>
  8. #include <dos/dos.h>
  9. #include <devices/scsidisk.h>
  10. #include <proto/exec.h>
  11. #include <proto/dos.h>
  12.  
  13. #include <string.h>
  14.  
  15. UBYTE    version[] = "$VER: eject 1.0 for the NEC CDR-210 drive";
  16.  
  17. ULONG    sense [5];
  18. UBYTE    buffer [10];
  19. UBYTE    cmd_eject[]    = { 0xDC,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 };
  20.  
  21. #define TEMPLATE "DEVICE/A,UNIT/N/A,OPEN/S,CLOSE/S"
  22.  
  23. struct {
  24.     STRPTR    device;
  25.     ULONG    unit;
  26.     BOOL    open;
  27.     BOOL    close;
  28. } args;
  29.  
  30. ULONG main (VOID)
  31. {
  32.     struct MsgPort *mp;
  33.     struct SCSICmd scsi;
  34.     struct RDArgs *rdargs;
  35.     struct IOStdReq *ior;
  36.     
  37.     if (rdargs = ReadArgs(TEMPLATE,(LONG*)&args,NULL))
  38.     {
  39.         if(mp=CreateMsgPort())
  40.         {
  41.             if(ior=(struct IOStdReq*)CreateIORequest(mp,sizeof(struct IOStdReq)))
  42.             {
  43.                 if(!OpenDevice(args.device,*(ULONG*)args.unit,ior,0))
  44.                 {
  45.                     ior->io_Command    = HD_SCSICMD;
  46.                     ior->io_Data    = (APTR) &scsi;
  47.                     ior->io_Length    = sizeof(struct SCSICmd);
  48.  
  49.                     scsi.scsi_Data        = (UWORD*) buffer;
  50.                     scsi.scsi_Length    = 0;
  51.                     scsi.scsi_CmdLength    = 10;
  52.                     scsi.scsi_Flags        = SCSIF_AUTOSENSE|SCSIF_WRITE;
  53.                     scsi.scsi_SenseData    = (UBYTE*) sense;
  54.                     scsi.scsi_SenseLength    = 20;
  55.                     scsi.scsi_Command    = cmd_eject;
  56.  
  57.                     DoIO(ior);
  58.  
  59.                     CloseDevice((struct IORequest*)ior);
  60.                 }
  61.                 DeleteIORequest((struct IORequest*)ior);
  62.             }
  63.             DeleteMsgPort(mp);
  64.         }
  65.         FreeArgs(rdargs);
  66.     }
  67.     else PrintFault(IoErr(),0);
  68.  
  69.     return RETURN_OK;
  70. }
  71.